image: alpine:edge

stages:
  - build

variables:
  GIT_SUBMODULE_STRATEGY: normal

before_script:
  - echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
  - apk update
  - apk add musl-dev eudev-libs eudev-dev linux-headers meson ninja gcc scdoc
  - apk add pixman-dev freetype-dev fontconfig-dev
  - apk add libxcb-dev xcb-util-wm-dev xcb-util-cursor-dev yaml-dev
  - apk add wayland-dev wayland-protocols wlroots-dev
  - apk add json-c-dev libmpdclient-dev alsa-lib-dev
  - apk add ttf-dejavu

debug:
  stage: build
  script:
    - apk add gcovr
    - mkdir -p bld/debug
    - cd bld/debug
    - meson --buildtype=debug -Db_coverage=true ../..
    - ninja -k0
    - meson test --print-errorlogs
    - ninja coverage-html
    - mv meson-logs/coveragereport ../../coverage
    - ninja coverage-text
    - tail -2 meson-logs/coverage.txt
  artifacts:
    paths:
      - coverage
  coverage: '/^TOTAL.*\s+(\d+\%)$/'

# valgrind:
#   stage: build
#   script:
#     - apk add valgrind
#     - mkdir -p bld/debug
#     - cd bld/debug
#     - meson --buildtype=debug ../..
#     - ninja -k0
#     - meson test --verbose --wrapper "valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=3"

release:
  stage: build
  script:
    - mkdir -p bld/release
    - cd bld/release
    - meson --buildtype=minsize ../../
    - ninja -k0
    - meson test --print-errorlogs

x11_only:
  stage: build
  script:
    - mkdir -p bld/debug
    - cd bld/debug
    - meson --buildtype=debug -Dbackend-x11=enabled -Dbackend-wayland=disabled ../../
    - ninja -k0
    - meson test --print-errorlogs

wayland_only:
  stage: build
  script:
    - mkdir -p bld/debug
    - cd bld/debug
    - meson --buildtype=debug -Dbackend-x11=disabled -Dbackend-wayland=enabled ../../
    - ninja -k0
    - meson test --print-errorlogs

plugins_as_shared_modules:
  stage: build
  script:
    - mkdir -p bld/debug
    - cd bld/debug
    - meson --buildtype=debug -Dcore-plugins-as-shared-libraries=true ../../
    - ninja -k0
    - meson test --print-errorlogs
